import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpClientModule, HTTP_INTERCEPTORS }    from '@angular/common/http';
import { FormsModule } from '@angular/forms'; // <-- NgModel lives here
import { RouterModule, Routes } from '@angular/router';
import { AppComponent } from './app.component';
import { ConfigService } from './service/config.service';
import { NewsService } from './service/news.service';
import { NewslistComponent } from './news/newslist/newslist.component';
import { EditComponent } from './news/edit/edit.component';
import { CKEditorModule } from 'ng2-ckeditor';
import { TohtmlPipe } from './pipe/tohtml.pipe';
import { DetailComponent } from './news/detail/detail.component';
import { NewslistforuserComponent } from './news/newslistforuser/newslistforuser.component';
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
import { NgbCarouselConfig } from '@ng-bootstrap/ng-bootstrap';
import { ForshowComponent } from './carousel/forshow/forshow.component';
import { UploadComponent } from './carousel/upload/upload.component';
import { IndexComponent } from './bs/index/index.component';
import { EditcarouselComponent } from './carousel/editcarousel/editcarousel.component';
import { CarouselService } from './service/carousel.service';
import { SinglepagelistComponent } from './singlepage/singlepagelist/singlepagelist.component';
import { EditsinglepageComponent } from './singlepage/editsinglepage/editsinglepage.component';
import { UploadsinglepageComponent } from './singlepage/uploadsinglepage/uploadsinglepage.component';
import { SinglepageService } from './service/singlepage.service';
import { DetailsinglepageComponent } from './singlepage/detailsinglepage/detailsinglepage.component';
import { LoginComponent } from './login/login.component';
import { AuthService } from './service/auth.service';
import { Interceptor } from './service/interceptor.service';
import { AdminGuard } from './guard/admin.guard';
import { CourseindexComponent } from './course/courseindex/courseindex.component';
import { BookComponent } from './course/book/book.component';
import { TeacherComponent } from './course/teacher/teacher.component';
import { ClassroomComponent } from './course/classroom/classroom.component';
import { StudentComponent } from './course/student/student.component';
import { CourseService } from './service/course.service';
import { SchedulingComponent } from './course/scheduling/scheduling.component';

export const ROUTES: Routes = [
{path:'newslist',component:NewslistComponent,canActivate:[AdminGuard]},
{path:'editnews/:id',component:EditComponent,canActivate:[AdminGuard]},
{path:'detail/:id',component:DetailComponent,canActivate:[AdminGuard]},
{path:'newslistforuser',component:NewslistforuserComponent,canActivate:[AdminGuard]},
{path:'showcarousel',component:ForshowComponent,canActivate:[AdminGuard]},
{path:'uploadfile',component:UploadComponent,canActivate:[AdminGuard]},
{path:'index',component:IndexComponent},
{path:'editCarousel/:id',component:EditcarouselComponent,canActivate:[AdminGuard]},
{path:'showSinglepagelist',component:SinglepagelistComponent,canActivate:[AdminGuard]},
{path:'editSinglepage/:id',component:EditsinglepageComponent,canActivate:[AdminGuard]},
{path:'uploadSinglepage',component:UploadsinglepageComponent,canActivate:[AdminGuard]},
{path:'detailsinglepage/:id',component:DetailsinglepageComponent,canActivate:[AdminGuard]},
{path:'courseindex',component:CourseindexComponent,canActivate:[AdminGuard]},
{path:'login',component:LoginComponent},
{path:'book',component:BookComponent,canActivate:[AdminGuard]},
{path:'teacher',component:TeacherComponent,canActivate:[AdminGuard]},
{path:'classroom',component:ClassroomComponent,canActivate:[AdminGuard]},
{path:'student',component:StudentComponent,canActivate:[AdminGuard]},
{path:'scheduling',component:SchedulingComponent,canActivate:[AdminGuard]},

{path:'**',component:LoginComponent},

];


@NgModule({
  declarations: [
    AppComponent,
    NewslistComponent,
    EditComponent,
    TohtmlPipe,
    DetailComponent,
    NewslistforuserComponent,
    ForshowComponent,
    UploadComponent,
    IndexComponent,
    EditcarouselComponent,
    SinglepagelistComponent,
    EditsinglepageComponent,
    UploadsinglepageComponent,
    DetailsinglepageComponent,
    LoginComponent,
    CourseindexComponent,
    BookComponent,
    TeacherComponent,
    ClassroomComponent,
    StudentComponent,
    SchedulingComponent,
  ],
  imports: [
    BrowserModule,
    HttpClientModule,
    FormsModule,
    RouterModule.forRoot(ROUTES),
    CKEditorModule,
    NgbModule
  ],
  providers: [
    ConfigService,
    NewsService,
    NgbCarouselConfig,
    CarouselService,
    SinglepageService,
    AuthService,
    { provide: HTTP_INTERCEPTORS, useClass: Interceptor, multi: true },
    AdminGuard,
    CourseService
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
